﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for cls_tbHOADON_BANGKEHOADON_CHON_IN
/// </summary>
public class cls_tbHOADON_BANGKEHOADON_CHON_IN
{
	public cls_tbHOADON_BANGKEHOADON_CHON_IN()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public static DataTable GetbyMaCN(string F_MACN)
    {
        DataTable dt = new DataTable();
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        SqlParameter[] para = new SqlParameter[1];
        para[0] = new SqlParameter("@F_MACN", F_MACN);
        try
        {
            dt = connect.GetSelectCommand("tbHOADON_BANGKEHOADON_CHON_IN_GetbyMaCN", para);
        }
        catch { }
        return dt;
    }
    public static DataTable GetbyMaCN_and_KT(string F_MACN, int KT)
    {
        DataTable dt = new DataTable();
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        SqlParameter[] para = new SqlParameter[2];
        para[0] = new SqlParameter("@F_MACN", F_MACN);
        para[1] = new SqlParameter("@KT", KT);
        try
        {
            dt = connect.GetSelectCommand("tbHOADON_BANGKEHOADON_CHON_IN_GetbyMaCN_and_KT", para);
        }
        catch { }
        return dt;
    }
    /// <summary>
    /// Store ko can NGAY, THANG, NAM 
    /// </summary>
    /// <param name="F_MACN"></param>
    /// <param name="NGAY"></param>
    /// <param name="THANG"></param>
    /// <param name="NAM"></param>
    /// <param name="F_SoHD"></param>
    /// <returns></returns>
    public static DataTable GetbyMaCN_to_IN(string F_MACN, string NGAY, string THANG, string NAM, string F_SoHD)
    {
        DataTable dt = new DataTable();
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        SqlParameter[] para = new SqlParameter[5];
        para[0] = new SqlParameter("@F_MACN", F_MACN);
        para[1] = new SqlParameter("@NGAY", NGAY);
        para[2] = new SqlParameter("@THANG", THANG);
        para[3] = new SqlParameter("@NAM", NAM);
        para[4] = new SqlParameter("@F_SoHD", F_SoHD);
        try
        {
            dt = connect.GetSelectCommand("tbHOADON_BANGKEHOADON_CHON_IN_GetbyMaCN_to_IN", para);
        }
        catch { }
        return dt;
    }
    public static string Delete(string F_MACN)
    {
        DatabaseConnect connect = new DatabaseConnect();

        // Tham so
        SqlParameter[] para = new SqlParameter[1];
        para[0] = new SqlParameter("@F_MACN", F_MACN);

        try
        {
            connect.ExecuteQuery("tbHOADON_BANGKEHOADON_CHON_IN_Delete_Group_byMaCN", para);
            return "OK";
        }
        catch { return "ERR"; }
    }
    public static string Insert(int ID)
    {
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        SqlParameter[] para = new SqlParameter[1];
        para[0] = new SqlParameter("@ID", ID);
        
        try
        {
            connect.ExecuteQuery("tbHOADON_BANGKEHOADON_CHON_IN_Insert_from_tbhoadonduocchon", para);
            return "OK";
        }
        catch
        { return "ERR"; }
    }
}